@using OrchardCore.DisplayManagement.Zones
@{
    var tabs = (IEnumerable<string>)ZoneShapes.HarvestAndSortTabs(Model.Parts);
}

<style asp-src="~/OrchardCore.Contents/Styles/Contents.min.css" debug-src="~/OrchardCore.Contents/Styles/Contents.css"></style>

<div class="edit-container @(Model.Sidebar != null ? "sidebar" : "")">
    <div class="edit-body">
        <div class="edit-item-primary">
            @if (Model.Content != null)
            {
                <div class="edit-item-content">
                    @await DisplayAsync(Model.Content)
                </div>
            }
        </div>
        <div class="edit-item-parts">
            @if (tabs.Any())
            {
                @await DisplayAsync(await New.LocalNavigation(ContentItem: Model.ContentItem, Tabs: tabs))
            }
            @if (Model.Parts != null)
            {
                @await DisplayAsync(Model.Parts)
            }
        </div>

        @if (Model.Actions != null)
        {
        <div class="edit-item-secondary group">
            <div class="edit-item-actions form-group">
                @await DisplayAsync(Model.Actions)

                @{
                    var returnUrl = Context.Request.Query["returnUrl"];
                }

                @if (!String.IsNullOrWhiteSpace(returnUrl) && Url.IsLocalUrl(returnUrl))
                {
                    <a id="button-cancel" href="@returnUrl" class="btn btn-secondary">@T["Cancel"]</a>
                }
            </div>
        </div>
        }
    </div>
    @if (Model.Sidebar != null)
    {
        <div class="edit-sidebar-handler"></div>
        <div class="edit-sidebar group">
            @await DisplayAsync(Model.Sidebar)
        </div>
    }
</div>

@if (Model.Actions != null)
{
    @if (!String.IsNullOrWhiteSpace(Context.Request.Query["returnUrl"]))
    {
        @Html.Hidden("returnUrl", Context.Request.Query["returnUrl"])
    }
}
